<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="制作单打印" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintCallBack()");
	}
	function doPrintCallBack(){
		if(popRetVal!=null){
			document.getElementById("noPrinSpan").style.display="none";
			doPrintLog();
		}
	}
	function doPrintLog(){
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", "/business/BusinessBillPrintLog.ihtm?id=${id}&type=MAKE");
		xmlHttp.onreadystatechange = function(){callback(xmlHttp)};
		xmlHttp.send(null);
	}
	function callback(xmlHttp){
    	if (xmlHttp.readyState == 4) {
      		if (xmlHttp.status == 200) {
      			var resTxt=xmlHttp.responseText;
      			if(resTxt=="NO_LOGIN"){
      				ShowAlert('提示框','你还没登录或已经超时，请重新登录。',200,100);
      			}else if(resTxt=="OK"){
					printContent("管理易-制作单","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}");
      			}
      			document.getElementById("noPrinSpan").style.display="";
			}
		}
	}
	function doCancel(){
		window.close();
	}
	function printImageOnload(obj){
		obj.style.display="";//现在才显示，避免先会把页面撑大,再缩小
		obj.width=obj.width>500?500:obj.width;//要放在display后，否则width=0
	}
</script>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery-barcode.js"></script>
<script language="javascript">
	var settings = {
			output: "css",
          	showHRI: false,
          	bgColor: "#FFFFFF",
      		color: "#000000",
          	barWidth: 1,
          	barHeight: 30
	};
	//var btype="code39";
	var btype="code128";
	function showBarcode(value,objName){
		$("#"+objName).html("").show().barcode(value, btype, settings);
	}
</script>
</head>
<body style="background-color:#FFFFFF">
<c:forEach var="record" items="${list}" varStatus="bi">
<c:if test="${bi.index>0}"><div class='PageNext'>&nbsp;</div></c:if>
<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="40px" align="center" class="FontLarge_Bold">${licenseInfo.enterpriseName} 制作单</td>
				</tr>
				<tr>
					<td align="right" valign="bottom">
						<div id="barcodeTarget${bi.index}"></div>
						<div class="FontSmall" style="padding-right:8px;">${record.clientCode}&nbsp;&nbsp;NO.&nbsp;${record.businessBill.billCode}</div>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="70%">订货单位：<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_CLIE_NAME;')==-1}">${record.clientName} </c:if><c:if test="${record.makePphone=='Y'}">${record.businessBill.linkman} ${record.businessBill.phone}</c:if></td>
			      	<td class="FontSmall" width="30%" align="right" style="padding-right:8px">订货日期：<fmt:formatDate value="${record.businessBill.orderDate}" pattern="yyyy-MM-dd HH:mm"/></td>
				</tr>
				<tr class="ListTrPrint">
				  <td class="FontSmall">地址：<c:if test="${record.makePphone=='Y'}">${record.businessBill.address}</c:if></td>
			      <td class="FontSmall" align="right" style="padding-right:8px">交货日期：<fmt:formatDate value="${record.businessBill.deliverDate}" pattern="yyyy-MM-dd HH:mm"/></td>
			  </tr>
		  	</table>
		</td>
	</tr>
	<tr>
		<td>
			<table><tr><td height="3"></td></tr></table>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
					<td width="10%" class="FontSmall_Bold" align="center">项目类型</td>
					<td width="15%" class="FontSmall_Bold" align="center">内容</td>
					<td width="13%" class="FontSmall_Bold" align="center">材质</td>
					<td width="17%" class="FontSmall_Bold" align="center">规格(宽X高)</td>
					<td width="6%" class="FontSmall_Bold" align="center">数量</td>
					<td width="8%" class="FontSmall_Bold" align="center">单位</td>
					<td width="10%" class="FontSmall_Bold" align="center">面积长度</td>
					<td width="21%" class="FontSmall_Bold" align="center">制作要求</td>
				</tr>
				<c:forEach var="item" items="${record.items}" varStatus="i">
				<tr class="ListTrPrint">
					<td class="FontSmall" align="center">${item.makeTypeName}</td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item.businessBillItem.finishedContent}" /></td>
					<td class="FontSmall" align="center">${item.businessBillItem.proName}</td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item.businessBillItem.specification}" /></td>
					<td class="FontSmall" align="center"><commonTag:parseBigDecimal source="${item.businessBillItem.amount}" /></td>
					<td class="FontSmall" align="center">
						<c:if test="${item.businessBillItem.priceType=='AREA'}">${item.unit}</c:if>
						<c:if test="${item.businessBillItem.priceType=='LENGTH'}">${item.unit}</c:if>
						<c:if test="${item.businessBillItem.priceType=='AMOUNT'}">${item.businessBillItem.unit}</c:if>
					</td>
					<td class="FontSmall" align="center">
						<c:if test="${item.businessBillItem.priceType=='AREA'}"><commonTag:parseBigDecimal source="${item.businessBillItem.squareNum}" />平米</c:if>
						<c:if test="${item.businessBillItem.priceType=='LENGTH'}">
							<commonTag:parseBigDecimal source="${item.businessBillItem.squareNum}" /><c:if test="${item.businessBillItem.lengType=='M'}">m</c:if><c:if test="${item.businessBillItem.lengType=='CM'}">cm</c:if>
						</c:if>
					</td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item.businessBillItem.makeRequire}" /></td>
				</tr>
				</c:forEach>
				<tr class="ListTrPrint">
					<td class="FontSmall" colspan="8" align="right">
						合计：
						<commonTag:parseBigDecimal source="${record.businessBill.square}" />平方米，
						<commonTag:parseBigDecimal source="${record.businessBill.lengM}" />米<commonTag:parseBigDecimal source="${record.businessBill.lengCm}" />公分，
						<commonTag:parseBigDecimal source="${record.businessBill.amount}" />&nbsp;
					</td>
				</tr>
			</table>
			
		</td>
	</tr>
	<c:if test="${fn:length(record.pathAccs)>0}">
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
					<td width="70%" class="FontSmall_Bold">存储路径</td>
					<td width="30%" class="FontSmall_Bold">文件说明</td>
				</tr>
				<c:forEach var="item" items="${record.pathAccs}" varStatus="i">
				<tr class="ListTrPrint">
					<td class="FontSmall">${item.customPath}</td>
					<td class="FontSmall">${item.mark}</td>
				</tr>
				</c:forEach>
			</table>
		</td>
	</tr>
	</c:if>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<colgroup>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=10%></col>
        			<col width=30%></col>
    			</colgroup>
				<c:if test="${enterpriseInfo.mbPrintImage=='Y' && fn:length(record.imgAccs)>0}">
		       	<c:forEach var="imgItem" items="${record.imgAccs}">
				<tr class="ListTrPrint">
					<td colspan="8" style="text-align:center"><img src="${imgItem.fileName}" style="display:none" onload="printImageOnload(this);"></td>
				</tr>
				</c:forEach>
				</c:if>
				<tr class="ListTrPrint">
					<td class="FontSmall_Bold">提货要求</td>
			      	<td class="FontSmall" colspan="5">${record.businessBill.ladingRequire}</td>
			      	<td class="FontSmall_Bold">安装要求</td>
			      	<td class="FontSmall">${record.businessBill.setupRequire}</td>
                </tr>
				<tr class="ListTrPrint">
 			       <td class="FontSmall_Bold">备注</td>
			      	<td class="FontSmall" colspan="7">${record.businessBill.mark}</td>
				</tr>
				<tr class="ListTrPrint">
					<td class="FontSmall_Bold">业务员</td>
			      	<td class="FontSmall">${record.businessBill.managerName}</td>
					<td class="FontSmall_Bold">跟单员</td>
			      	<td class="FontSmall">${record.businessBill.followerNameStr}</td>
					<td class="FontSmall_Bold">业务来源</td>
			      	<td class="FontSmall">${record.businessBill.introducerName}</td>
			      	<td class="FontSmall_Bold">设计员</td>
			      	<td class="FontSmall"><c:if test="${record.businessBill.designType=='SELF'}">公司设计 </c:if><c:if test="${record.businessBill.designType=='CLIENT'}">客户来稿 </c:if>${record.businessBill.designerNameStr}</td>
				</tr>
				<c:if test="${type!='COOPER'}">
				<tr class="ListTrPrint" height="35">
					<td class="FontSmall_Bold">产量登记</td>
			      	<td class="FontSmall" colspan="7"><b>${record.makerStr}</b></td>
				</tr>
				</c:if>
		  </table>
		</td>
	</tr>
	
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center" class="ListTable">
				<tr class="ListTrPrint">
					<td class="FontSmall" width="25%">开单人:${record.businessBill.createrName}</td>
					<td class="FontSmall" width="25%">审核人:${record.businessBillExt.examinerName}</td>
					<td class="FontSmall" width="25%">制作主管:</td>
					<td class="FontSmall" width="25%">确认:</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<c:if test="${codeRule.printFoot!=null && codeRule.printFoot!=''}">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td class="FontSmall"><commonTag:parseEnterToBr source="${codeRule.printFoot}" /></td>
				</tr>
			</table>
		</td>
	</tr>
	</c:if>
</table>
<c:if test="${enterpriseInfo.makeBc=='Y'}">
<script language="javascript">
	showBarcode('${record.businessBill.billCode}','barcodeTarget${bi.index}');
</script>
</c:if>
</c:forEach>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="noPrinSpan">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr height="30">
					<td>
						<input type="button" id="printButton" class="Button" value="开始打印" onClick="doPrint();">
						<input type="button" id="cancelButton" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>